package com.ruoyi.basedocument.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basedocument.mapper.BomCustomerMapper;
import com.ruoyi.basedocument.domain.BomCustomer;
import com.ruoyi.basedocument.service.IBomCustomerService;

/**
 * 客户Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-23
 */
@Service
public class BomCustomerServiceImpl implements IBomCustomerService 
{
    @Autowired
    private BomCustomerMapper bomCustomerMapper;

    /**
     * 查询客户
     * 
     * @param id 客户主键
     * @return 客户
     */
    @Override
    public BomCustomer selectBomCustomerById(String id)
    {
        return bomCustomerMapper.selectBomCustomerById(id);
    }

    /**
     * 查询客户列表
     * 
     * @param bomCustomer 客户
     * @return 客户
     */
    @Override
    public List<BomCustomer> selectBomCustomerList(BomCustomer bomCustomer)
    {
        return bomCustomerMapper.selectBomCustomerList(bomCustomer);
    }

    /**
     * 查询客户列表
     *
     * @param bomCustomer 客户
     * @return 客户
     */
    @Override
    public List<BomCustomer> selectBomCustomerList2(BomCustomer bomCustomer)
    {
        return bomCustomerMapper.selectBomCustomerList2(bomCustomer);
    }

    /**
     * 新增客户
     * 
     * @param bomCustomer 客户
     * @return 结果
     */
    @Override
    public int insertBomCustomer(BomCustomer bomCustomer)
    {
        BomCustomer bomCustomer1 = new BomCustomer();
        bomCustomer1.setCustomernumber(bomCustomer.getCustomernumber());
        List<BomCustomer> bomCustomers = selectBomCustomerList2(bomCustomer1);
        if(bomCustomers!=null&&bomCustomers.size()!=0){
            throw new RuntimeException("编码已存在:"+bomCustomer.getCustomernumber());
        }
        return bomCustomerMapper.insertBomCustomer(bomCustomer);
    }

    /**
     * 修改客户
     * 
     * @param bomCustomer 客户
     * @return 结果
     */
    @Override
    public int updateBomCustomer(BomCustomer bomCustomer)
    {
        return bomCustomerMapper.updateBomCustomer(bomCustomer);
    }

    /**
     * 批量删除客户
     * 
     * @param ids 需要删除的客户主键
     * @return 结果
     */
    @Override
    public int deleteBomCustomerByIds(String[] ids)
    {
        return bomCustomerMapper.deleteBomCustomerByIds(ids);
    }

    /**
     * 删除客户信息
     * 
     * @param id 客户主键
     * @return 结果
     */
    @Override
    public int deleteBomCustomerById(String id)
    {
        return bomCustomerMapper.deleteBomCustomerById(id);
    }
}
